<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>综合案例-ATM存取款机</title>
</head>

<body>
  <script>
    // 综合案例 - ATM存取款机
    // 提前声明金额变量 money
    let money = 100
    // 1.提示输入框写到循环里面（无限循环）
    while (true) {
      let num = +prompt(`
      请选择您的操作:
        1.取款
        2.存款
        3.查看余额
        4.退出
    `)
      if (num === 1) {
        let qu = +prompt('请您输入取款金额:')
        // money = money - qu
        money -= qu
      } else if (num === 2) {
        let cun = +prompt('请您输入存款金额:')
        // money = money + cun
        money += cun
      } else if (num === 3) {
        alert(`您的银行卡余额是: ${money}`)
      } else if (num === 4) {
        // 2.用户输入4则退出循环 break   一定要小心数据类型
        break
      }
    }
    document.write(`滴，您的银行卡余额为: ${money}元，请节约消费`)
  </script>
</body>

</html>